import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ArticleVo, ArticleForm, ArticleQuery } from '@/api/article/types';

//article列表
export const getListArticle = (query: ArticleQuery): AxiosPromise<ArticleVo[]> => {
  return request({
    url: '/article/list',
    method: 'get',
    params: query
  });
};

//添加article
export const saveArticle = (data: ArticleForm) =>{
  return request({
    url: '/article/saveArticle',
    method: 'post',
    headers: {
      repeatSubmit: false
    },
    data: data
  });
};

//修改article
export const updateArticle = (data: ArticleForm) => {
  return request({
    url: '/article/updateArticle',
    method: 'post',
    headers: {
      repeatSubmit: false
    },
    data: data
  });
};

//删除article
export const removeArticle = (id: string | number | Array<string | number>) => {
  return request({
    url: '/article/' + id,
    method: 'delete'
  });
};

//获取article
export const getArticle = (id: string | number): AxiosPromise<ArticleVo> => {
  return request({
    url: '/article/' + id,
    method: 'get'
  });
};
